<?php
include ("inc/head-html.php");
include_once("inc/session.php");
?>

  <script>
    var mygrid;
    function doInit(){
             formData =  [
                      { type:"settings" , labelWidth:80, inputWidth:250, position:"absolute"  },
	                    { type:"input" , name:"NOM", label:"Nom", labelAlign:"left", inputWidth:345, labelLeft:140, labelTop:5, inputLeft:220, inputTop:5  },
                      { type:"button" , name:"rem", label:"Supprimer Ligue", value:"Supprimer Ligue", width:"125", inputWidth:125, inputLeft:5, inputTop:5  },
                  		{ type:"button" , name:"add", label:"Ajouter Ligue", value:"Ajouter Ligue", width:"125", inputWidth:125, inputLeft:5, inputTop:30  },
	                    { type:"button" , name:"save", label:"Sauver", value:"Sauver", width:"125", inputWidth:125, inputLeft:5, inputTop:55 }
                  ] ;
                  
          var dhxLayout2 = dhxMainLayout.cells("c").attachLayout("2U");        
          dhxMainLayout.cells("b").attachObject("navig");
          var mygrid = dhxLayout2.cells("a").attachGrid();
          var myForm = dhxLayout2.cells("b").attachForm(formData);


          mygrid.setImagePath("codebase/imgs/");
          mygrid.setHeader("Nom");
          mygrid.setColumnIds("NOM");
          mygrid.setInitWidths("150");
          mygrid.setColAlign("left");
          mygrid.setColTypes("ed");
          mygrid.setSkin("modern");
          mygrid.init();

          mygrid.load("ligues.php");
          mygrid.enableSmartRendering(true); 
          mygrid.enableEditEvents(false, true, true);
          dp = new dataProcessor("ligues.php");
          dp.init(mygrid); 
            
          myForm.bind(mygrid);  
          
          myForm.attachEvent("onButtonClick", function(name, command){
           if(name=="add"){
              var newId = (new Date()).valueOf();
              mygrid.addRow(newId,"") ;
              mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);
            }
           if(name=="rem"){
              var selId = mygrid.getSelectedId();
              mygrid.deleteRow(selId); 
            }
           if(name=="save"){
                myForm.save();
            }
        });
          
          

    }
    
  </script>
  
  
<div id="navig"><h2><a href="index.php">Gestion Compétition FSCF</a>-><a href="admin.php">Administration</a>-><a href="admin_ligues.php">Ligues</a></h2></div>>
<?php

include ("inc/foot-html.php");
?>
